﻿using Cloud.BLL;
using Cloud.Model;
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class Three_Managerment_Problem_two_CountProblem : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        try
        {
            if (Session["users"] == null)
            {
                Response.Write("<script>alert('登录超时'); window.parent.location.href='/index.html'</script>");
            }
            if (!IsPostBack)
            {
                bind2();
                bind3();
            }
        }
        catch (Exception ex)
        {
            Response.Write("<script>alert('登陆信息失效,请重新登陆!'); window.parent.location.href='/index.html'</script>");
            return;
        }
    }

    protected void AspNetPager2_PageChanged(object sender, EventArgs e)
    {
        try
        {
            if (Session["users"] == null)
            {
                Response.Write("<script>alert('登录超时'); window.parent.location.href='/index.html'</script>");
            }
            bind2();
        }
        catch (Exception ex)
        {
            Response.Write("<script>alert('登陆信息失效,请重新登陆!'); window.parent.location.href='/index.html'</script>");
            return;
        }
    }

    protected void AspNetPager3_PageChanged(object sender, EventArgs e)
    {
        try
        {
            if (Session["users"] == null)
            {
                Response.Write("<script>alert('登录超时'); window.parent.location.href='/index.html'</script>");
            }
            bind3();
        }
        catch (Exception ex)
        {
            Response.Write("<script>alert('登陆信息失效,请重新登陆!'); window.parent.location.href='/index.html'</script>");
            return;
        }
    }

    public void bind2()
    {
        try
        {
            SqlConnection connection = new SqlConnection(ConfigurationManager.ConnectionStrings["ConString"].ConnectionString);
            SqlCommand cmd = new SqlCommand("select DW.DWMC,DW.DWBH,ISNULL((select count(*) from problem where handle_type = 0 and problem.zrdwid = DW.DWBH),0) as db,ISNULL((select count(*) from problem where handle_type = 1 and problem.zrdwid = DW.DWBH),0) as blz,ISNULL((select count(*) from problem where handle_type = 2 and problem.zrdwid = DW.DWBH),0) as ybl,ISNULL((select count(*) from problem where handle_type = 3 and problem.zrdwid = DW.DWBH),0) as ybj from DW where DW.DWLB = 2 and DW.DWBH='" + ((USER_INFO)Session["users"]).DEPARTMENT + "' order by DW.DWBH desc ", connection);
            SqlDataAdapter sda = new SqlDataAdapter(cmd);
            DataSet ds = new DataSet();
            DataSet ds2 = new DataSet();
            AspNetPager2.PageSize = 10;//设置分页大小 
            //AspNetPager1.RecordCount = ProblemManager.Bm0_db_all().Count;//设置总数据条数 
            sda.Fill(ds2);
            AspNetPager2.RecordCount = ds2.Tables[0].Rows.Count;//设置总数据条数 
            sda.Fill(ds, AspNetPager2.PageSize * (AspNetPager2.CurrentPageIndex - 1), AspNetPager2.PageSize, "problem");//固定不变的 
            repeater2.DataSource = ds.Tables["problem"];
            repeater2.DataBind();
        }
        catch (Exception ex)
        {
            Response.Write("<script>alert('登陆信息失效,请重新登陆!'); window.parent.location.href='/index.html'</script>");
            return;
        }

    }
    public void bind3()
    {
        try
        {
            SqlConnection connection = new SqlConnection(ConfigurationManager.ConnectionStrings["ConString"].ConnectionString);
            SqlCommand cmd = new SqlCommand("select DW.DWMC,DW.DWBH,ISNULL((select count(*) from problem where handle_type = 0 and problem.zrdwid = DW.DWBH),0) as db,ISNULL((select count(*) from problem where handle_type = 1 and problem.zrdwid = DW.DWBH),0) as blz,ISNULL((select count(*) from problem where handle_type = 2 and problem.zrdwid = DW.DWBH),0) as ybl,ISNULL((select count(*) from problem where handle_type = 3 and problem.zrdwid = DW.DWBH),0) as ybj from DW where DW.DWLB = 3 AND SJDW='" + ((USER_INFO)Session["users"]).DEPARTMENT + "' order by DW.DWBH desc ", connection);
            SqlDataAdapter sda = new SqlDataAdapter(cmd);
            DataSet ds = new DataSet();
            DataSet ds2 = new DataSet();
            AspNetPager3.PageSize = 10;//设置分页大小 
            sda.Fill(ds2);
            AspNetPager3.RecordCount = ds2.Tables[0].Rows.Count;//设置总数据条数 
            //AspNetPager3.RecordCount = ds.Tables["problem"].Rows.Count;//设置总数据条数 
            sda.Fill(ds, AspNetPager3.PageSize * (AspNetPager3.CurrentPageIndex - 1), AspNetPager3.PageSize, "problem");//固定不变的 

            repeater3.DataSource = ds.Tables["problem"];

            repeater3.DataBind();
        }
        catch (Exception ex)
        {
            Response.Write("<script>alert('登陆信息失效,请重新登陆!'); window.parent.location.href='/index.html'</script>");
            return;
        }
    }
    protected void repeater_ItemDataBound(object sender, RepeaterItemEventArgs e)
    {
        //if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
        //{
        //    Repeater rep = e.Item.FindControl("rep1") as Repeater;//找到里层的repeater对象
        //    DataRowView rowv = (DataRowView)e.Item.DataItem;//找到分类Repeater关联的数据项 
        //    int typeid = Convert.ToInt32(rowv["source_id"]); //获取填充子类的id 
        //    IList<Sources> sou = new List<Sources>();
        //    sou.Add(SourcesManager.FindById(typeid));
        //    rep.DataSource = sou;
        //    rep.DataBind();
        //}
    }

    //事件状态
    public string sjzt(int i)
    {
        try
        {
            String zts = "";
            if (i == 0)
            {
                zts = "待办理";
            }
            else if (i == 1)
            {
                zts = "办理中";
            }
            else if (i == 2)
            {
                zts = "已办理";
            }
            else if (i == 3)
            {
                zts = "已办结";
            }
            else if (i == 4)
            {
                zts = "直办";
            }
            return zts;
        }
        catch (Exception ex)
        {
            Response.Write("<script>alert('登陆信息失效,请重新登陆!'); window.parent.location.href='/index.html'</script>");
            return "";
        }

    }
}